{include file="public/header" /}
{load href="__PLUGINS__iCheck/icheck.min.js"}
{load href="__PLUGINS__iCheck/custom.css"}

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post">
            <div class="col-sm-12">
                <div class="tabs-container">

                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div class="ibox-content">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">名称：</label>
                                    <div class="col-sm-9">
                                        <input name="title" type="text" class="form-control" value="{present name='name'}{$name.title}{/present}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">绑定到相关类型：</label>
                                    <div class="col-sm-4">
                                        <select class="form-control" id="cateselect" name="category" lay-search>
                                            <option value=''></option>
                                            {volist name='category' id='v'}
                                            <option value="{$v.id}" {present name="name"}{eq name="name.category" value="$v.id" }selected{/eq}{/present}>{:str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $v['depth'])}{gt name="$v['depth']" value="0"}┠&nbsp;&nbsp;{/gt}{$v.name}</option>
                                            {/volist}
                                        </select>
                                        <span class="help-block m-b-none" style="color:rgba(0,0,0,0.4)">若当前榜单未添加内容则系统根据帖子类型自动列出热度高的帖子</span>
                                    </div>
                                    <div class="col-sm-5" style="display: flex;">
                                        <input type="text" class="form-control" id="searchcate" placeholder="快捷搜索分类">
                                        <span class="btn btn-primary " onclick="searchcate()">搜索</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">排序：</label>
                                    <div class="col-sm-9">
                                        <input name="sort" type="text" class="form-control" value="{present name='name'}{$name.sort}{else /}0{/present}">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{include file="public/footer" /}

<script type="text/javascript">
    $(document).ready(function(){
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        })

    });
    function searchcate() {
        let keyword = $('#searchcate').val();
        ajaxFun("post","{:url('article/searchcate')}",{keyword},'json',function(ret){
            if(ret){
                let html = ''
                ret.forEach(item=>{
                    html += `<option value="${item.id}">${item.depth ? '&nbsp;&nbsp;&nbsp;&nbsp;┠&nbsp;&nbsp;' : ''}${item.name}</option>`
                })
                $('#cateselect').html(html)
            }else{
                swal_msg("错误",ret,"error");
            }
        })
    }
</script>
{include file="public/bottom" /}